import java.util.concurrent.Callable;

/**
 * 线程测试
 *
 * @author DiXiaoNie
 * @date 2022/12/27
 * @since 2022/12/27 9:56
 */

public class ThreadTest {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        myThread.setName("MyThread-");
        myThread.start();

        MyRunable myRunable = new MyRunable();
        Thread thread = new Thread(myRunable);
        thread.setName("MyRunable-");
        thread.start();

        MyCallable myCallable = new MyCallable();


        System.out.println(Thread.currentThread().getName() + "-" + System.currentTimeMillis());
    }


    public static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + System.currentTimeMillis());
        }
    }

    public static class MyRunable implements Runnable {

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + System.currentTimeMillis());
        }
    }

    public static class MyCallable implements Callable<String> {
        /**
         * Computes a result, or throws an exception if unable to do so.
         *
         * @return computed result
         * @throws Exception if unable to compute a result
         */
        @Override
        public String call() throws Exception {
            System.out.println(Thread.currentThread().getName() + System.currentTimeMillis());
            return "OK";
        }
    }


}
